import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TelDeviceVO, TelDeviceForm, TelDeviceQuery } from '@/api/device/telDevice/types';

/**
 * 查询视频话机管理列表
 * @param query
 * @returns {*}
 */

export const listTelDevice = (query?: TelDeviceQuery): AxiosPromise<TelDeviceVO[]> => {
  return request({
    url: '/device/telDevice/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询视频话机管理详细
 * @param id
 */
export const getTelDevice = (id: string | number): AxiosPromise<TelDeviceVO> => {
  return request({
    url: '/device/telDevice/' + id,
    method: 'get'
  });
};

/**
 * 新增视频话机管理
 * @param data
 */
export const addTelDevice = (data: TelDeviceForm) => {
  return request({
    url: '/device/telDevice',
    method: 'post',
    data: data
  });
};

/**
 * 修改视频话机管理
 * @param data
 */
export const updateTelDevice = (data: TelDeviceForm) => {
  return request({
    url: '/device/telDevice',
    method: 'put',
    data: data
  });
};

/**
 * 删除视频话机管理
 * @param id
 */
export const delTelDevice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/device/telDevice/' + id,
    method: 'delete'
  });
};

/**
 * 重启设备
 * @param id
 */
export const restartDevice = (data: any) => {
  return request({
    url: '/device/telDevice/restart',
    method: 'post',
    data
  });
};

/**
 * 更新配置
 * @param id
 */
export const updateConfig = (data: any) => {
  return request({
    url: '/device/telDevice/updateConfig',
    method: 'post',
    data
  });
};

/**
 * 更新用户
 * @param id
 */
export const updateUser = (data: any) => {
  return request({
    url: '/device/telDevice/updateUser',
    method: 'post',
    data
  });
};

/**
 * 同步话机设备列表
 * @param query
 * @returns {*}
 */

export const syncXltDeviceList = (query?: TelDeviceQuery): AxiosPromise<any> => {
  return request({
    url: '/ghAppController/syncXltDeviceList',
    method: 'get',
    params: query
  });
};
